package com.hbnu.util;

import lombok.Getter;
import org.hibernate.Session;
import org.hibernate.SessionFactory;

import org.hibernate.cfg.Configuration;
public class HibernateUtils {
    private static SessionFactory sessionFactory;
    private static Configuration configuration;

    static {
        configuration = new Configuration().configure();
        sessionFactory = configuration.buildSessionFactory();
    }

    public static SessionFactory getSessionFactory() {return sessionFactory;}

    public static Session getSession() {
        return sessionFactory.getCurrentSession(); // 获取当前线程绑定的session
    }

    public static void main(String[] args) {

    }
}
